<?php

$MDPF = '" disabled readonly="';

if (isset($_POST['OBJCTCL'])) {
    $OBJCTCL = $_POST['OBJCTCL'];
    $MDPF = '';
}
if (isset($_POST['CliProfile'])) {
    $MYT->db_query("UPDATE clientes SET CliProfile = {$_POST['CliProfile']},
	 CliClass = {$_POST['CliClass']} WHERE CliNumero = {$OBJCTCL}");
}
    echo '<script charset="utf-8" type="text/javascript">
			document.getElementById(\'PrfGfx\').src=\'_response/bin.php?get=Profiles/Cl/prf01.png\';
                        </script>';

$CLPROFILE = $MYT->db_array("SELECT
			CliProfile,
			CliClass,
			b.REF,
			b.EventLevel,
			hc_st.VALUE,
			hc_st.FILE
			 FROM clientes
			LEFT OUTER JOIN hc_profiles AS b ON b.SENDER = CliNumero
			LEFT OUTER JOIN hcw_profilesetts AS hc_st ON hc_st.REF = b.TYPE AND hc_st.TYPE = 1
			WHERE CliNumero = {$OBJCTCL}");

if (isset($CLPROFILE[1])) {

    $CLPRF1 = $CLPROFILE[1]['VALUE'];
    if ($CLPROFILE[1]['EventLevel'] != 0) {
        echo '<script charset="utf-8" type="text/javascript">
			document.getElementById(\'PrfGfx\').src=\'_response/bin.php?get=Profiles/Cl/' . $CLPROFILE[1]['FILE'] . '\';
			</script>';
    }
} else {
    $CLPROFILE[1]['CliProfile'] = 1;
    $CLPROFILE[1]['CliClass'] = 1;
}
$ViewProfiles = '';
$ViewClasses = '';
$Profiles = "SELECT REF AS ID, VALUE AS NAME FROM hcw_profilesetts";
$Classes = "SELECT chc_ID AS ID, chc_Name AS NAME FROM hc_class WHERE chc_ID = {$CLPROFILE[1]['CliClass']}";
if ($MDPF != '') {
    $ViewProfiles = $GLOBALS['MYT']->db_array($Profiles . " WHERE REF = " . $CLPROFILE[1]['CliProfile']);
    $ViewProfiles = $ViewProfiles[1]['NAME'];
    $ViewClasses = $GLOBALS['MYT']->db_array($Classes);
    $ViewClasses = $ViewClasses[1]['NAME'];
}
$Profiles .= " WHERE REF > 0";
echo 'Perfil:';
mn_field('select', 'ED', 'CliProfile', $CLPROFILE[1]['CliProfile'], $Profiles, $ViewProfiles, '', $MDPF . '" onchange="
			document.ClientProperties.action=\'_response/call.php?get=Operative/view/viewclientprofile\';
			subform(\'ClientProperties\',\'Prf_Box\');');
echo ' | Classe:';
mn_field('select', 'ED', 'CliClass', $CLPROFILE[1]['CliClass'], $Classes, $ViewClasses, '', $MDPF . '" onchange="
			document.ClientProperties.action=\'_response/call.php?get=Operative/view/viewclientprofile\';
			subform(\'ClientProperties\',\'Prf_Box\');');